{
  var name = 'yuanmanxue';
  var obj = {
    name: 'yyyyy',
    getNameFn: function() {
      var self = this;
      return function() {
        return self.name
      }
    }
  }
  console.log(obj.getNameFn()());
}

{
  // function fun(n, o) {
  //   console.log(o);
  //   return {
  //     fun: function(m) {
  //       return fun(m, n);
  //     }
  //   }
  // }
  // var a = fun(0).fun(1);//
  // a.fun(2);
  // a.fun(3);
  // var b = fun(0).fun(1).fun(2).fun(3);
  // var c = fun(0);
  // c.fun(1);
  // c.fun(2);
  // c.fun(3);
}

{
  //求 10000 以内 3 和 5 的倍数和，写出JavaScript实现函数
  function getSum() {
    let sum = 0;
    for (let i = 0; i <= 1000; i++) {
      if (i % 3 === 0 || i % 5 === 0) {
        sum += i;
      }
    }
    console.log(sum);
  }
  getSum() //234168

}

{
  //数据去重复
  Array.prototype.isDouble = function() {
    var hashObject = {};
    for (var i = 0; i < this.length; i++) {
      if (hashObject[this[i]]) {
        this.splice(i, 1)
        i--;
      } else {
        hashObject[this[i]] = true;
      }
    }
  }
  var arr = new Array(1, 2, 3, 4, 1, 2, 3, 4, 56, 3, 2, 1, 4, 25, 23, 43, 2)
  arr.isDouble()
  console.log(arr)
}
{
  //快速排序的方法[3,23,66,32,2,77,45,87,64,34,33]
  let arr=[3,23,66,32,2,77,45,87,64,34,33];
var quickSort = function(arr) {
  if (arr.length <= 1) {
    return arr;
  }
  var pivot = arr.splice(Math.floor(arr.length / 2), 1)[0];
  // console.log(pivot);
  var left = [];
  var right = [];
  for (var i = 0; i < arr.length; i++) {
    var queue = right;
    if (arr[i] < pivot) {
      queue = left;
    }
    queue.push(arr[i]);
  }
  return quickSort(left).concat([pivot], quickSort(right));

};
quickSort(arr);
console.log(quickSort(arr));//[2, 3, 23, 32, 33, 34, 45, 64, 66, 87]
}

{
  window.firstName='yuan';
  window.lastName='manxue';
  let person={
    firstName:'yyy',
    lastName:'manxue'
  }
  function sayName(){
    // console.log(this.firstName,this.lastName);
    console.log(this);
  }
  sayName()
  sayName.call(person)
}
